package com.intelligence.device.cloud.messageConsumer;

import com.alibaba.fastjson2.JSON;
import com.intelligence.entity.pojo.DeviceLog;
import com.intelligence.openfeign.service.deivce.DeviceLogFeignService;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author : RulerWood
 * @Data : 2024/6/3 - 11:04
 */
@Component
public class GatherDataErrorConsumerService {

    @Autowired
    private DeviceLogFeignService deviceLogFeignService;

    @RabbitListener(queues = "gather-error-queue")
    public void deviceThresholdErrorInfo(Message message) {
        byte[] payload = message.getBody();
        DeviceLog deviceLog = JSON.parseObject(new String(payload), DeviceLog.class);
        System.err.println("gather-error-queue 收到消息：" + deviceLog);
        this.deviceLogFeignService.saveDeviceLog(deviceLog);
    }

}
